QUERY PLAN                                                                                                                                                                               
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Nested Loop Anti Join  (cost=10.42..119666.32 rows=4 width=4) (actual time=21086.559..21086.559 rows=0 loops=1)
   Buffers: shared hit=445188 read=61756
   ->  Nested Loop Anti Join  (cost=9.75..119602.41 rows=4 width=19) (actual time=21086.558..21086.558 rows=0 loops=1)
         Buffers: shared hit=445188 read=61756
         ->  Nested Loop Anti Join  (cost=9.31..119467.55 rows=4 width=19) (actual time=21086.557..21086.557 rows=0 loops=1)
               Buffers: shared hit=445188 read=61756
               ->  Nested Loop Anti Join  (cost=0.85..113201.38 rows=4 width=19) (actual time=21086.556..21086.556 rows=0 loops=1)
                     Buffers: shared hit=445188 read=61756
                     ->  Index Scan using emailrcpts_4columns on emailrcpts  (cost=0.56..113162.26 rows=5 width=29) (actual time=21086.555..21086.555 rows=0 loops=1)
                           Index Cond: ((cid = 1784539) AND (removed = false) AND (active = true) AND (bounce < 3))
                           Filter: ((NOT removed) AND active AND (email IS NOT NULL) AND (((fname IS NOT NULL) AND (length((fname)::text) <> 0)) OR ((lname IS NOT NULL) AND (length((lname)::text) <> 0))) AND (number_of_sends(id, 30, 1) < 3) AND (lower(get_make(cid, (vin)::text, (make_purchased)::text)) = 'ohgoshnonotthebees!!!'::text) AND (NOT (SubPlan 1)))
                           Rows Removed by Filter: 19952
                           Buffers: shared hit=445188 read=61756
                           SubPlan 1
                             ->  Limit  (cost=0.28..15.58 rows=1 width=0) (never executed)
                                   ->  Index Scan using client_products_active_cid on client_products  (cost=0.28..15.58 rows=1 width=0) (never executed)
                                         Index Cond: ((cid = 1784539) AND (cancel_date IS NULL))
                                         Filter: ((background_id = emailrcpts.id) AND (product_id = 1))
                     ->  Index Scan using bogus_email_lower_email on bogus_email_list  (cost=0.29..8.31 rows=1 width=19) (never executed)
                           Index Cond: ((email)::text = (emailrcpts.email)::text)
                           Filter: ((cid = 0) OR (cid = 1784539))
               ->  Hash Join  (cost=8.46..1259.41 rows=74 width=4) (never executed)
                     Hash Cond: (ooh_1.reason = oor.id)
                     ->  Index Scan using opt_out_history_sid on opt_out_history ooh_1  (cost=0.44..1250.30 rows=94 width=8) (never executed)
                           Index Cond: (sid = emailrcpts.id)
                           Filter: active
                     ->  Hash  (cost=7.02..7.02 rows=80 width=4) (never executed)
                           ->  Seq Scan on opt_out_reasons oor  (cost=0.00..7.02 rows=80 width=4) (never executed)
                                 Filter: global
         ->  Index Scan using opt_out_history_sid on opt_out_history ooh  (cost=0.44..1251.25 rows=56 width=4) (never executed)
               Index Cond: (sid = emailrcpts.id)
               Filter: (active AND (product_id = 1))
   ->  Index Scan using bn_name on bogus_name_list  (cost=0.68..12.72 rows=1 width=20) (never executed)
         Index Cond: (lower(emailrcpt_name(emailrcpts.fname, emailrcpts.lname)) = lower((name)::text))
         Filter: ((cid = 1784539) OR (cid = 0))
 Planning time: 9.105 ms
 Execution time: 21087.067 ms
(37 rows)